В конструктор ИнформацияОбОшибке, добавлен параметр "Причина" для возможности указания причины текущей ошибки#1494
Conversation
…можности указания причины текущей ошибки
WalkthroughThis pull request enhances exception handling capabilities across multiple classes in the ScriptEngine. The changes focus on improving the ability to track and propagate nested exceptions by introducing a new Changes
Sequence DiagramsequenceDiagram
participant Client
participant ExceptionInfoContext
participant ParametrizedRuntimeException
Client->>ExceptionInfoContext: Create(message, parameters, cause)
ExceptionInfoContext-->>Client: Return ExceptionInfoContext
Client->>ParametrizedRuntimeException: Raise with ExceptionInfoContext
ParametrizedRuntimeException-->>Client: Exception with cause preserved
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/ScriptEngine/Machine/Contexts/ExceptionInfoContext.cs (1)
198-208: Enhance XML documentation for the 'Create' method.The XML comments for the
Createmethod are incomplete. Providing detailed summaries and parameter descriptions improves code maintainability and developer understanding.Apply this diff to enhance the documentation:
/// <summary> -/// +/// Creates a new instance of ExceptionInfoContext with the ability to specify the cause of the exception. /// </summary> +/// <param name="msg">String - Error message</param> +/// <param name="parameter">Any - Additional information</param> +/// <param name="cause">ExceptionInfoContext - The cause of the current exception</param> /// <returns>ExceptionInfoContext instance.</returns>src/ScriptEngine/Machine/ParametrizedRuntimeException.cs (1)
9-9: Remove unnecessary using directive.The
using ScriptEngine.Machine.Contexts;directive is not used in this file. Removing it prevents clutter and adheres to clean code practices.Apply this diff to remove the unused directive:
-using ScriptEngine.Machine.Contexts;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/ScriptEngine/Machine/Contexts/ExceptionInfoContext.cs(4 hunks)src/ScriptEngine/Machine/ExceptionInfoFactory.cs(1 hunks)src/ScriptEngine/Machine/MachineInstance.cs(1 hunks)src/ScriptEngine/Machine/ParametrizedRuntimeException.cs(1 hunks)tests/global-funcs.os(2 hunks)
🔇 Additional comments (10)
src/ScriptEngine/Machine/Contexts/ExceptionInfoContext.cs (4)
36-40: Constructor enhancement looks good.The addition of the
causeparameter to the constructor allows for proper tracking of nested exceptions.
52-52: Assignment of 'Cause' property is appropriate.Assigning
pre.Causeto_innerExceptioncorrectly maintains the exception chain.
Line range hint
56-65: Verify the necessity of making 'ActualException()' method public.Changing
ActualException()from private to public exposes internal exception details. Ensure this change is intentional and does not leak sensitive information or break encapsulation.
152-153: Null-check on 'exc.InnerException' is handled correctly.The null-check prevents potential
NullReferenceExceptionwhen there is no inner exception.src/ScriptEngine/Machine/ParametrizedRuntimeException.cs (2)
15-18: Constructor modification is appropriate.Adding the optional
causeparameter to the constructor allows exceptions to carry additional context.
22-22: 'Cause' property added correctly.The
Causeproperty aligns with the constructor parameter, enabling access to the exception's cause.src/ScriptEngine/Machine/ExceptionInfoFactory.cs (1)
51-51: Update to 'Raise' method ensures proper exception propagation.Passing
excInfo.InnerExceptionto theParametrizedRuntimeExceptionconstructor allows for detailed exception context and proper chaining.tests/global-funcs.os (2)
80-80: LGTM!The new test case is properly registered in the test list.
892-934: LGTM! Well-structured test case for nested exception handling.The test case thoroughly verifies:
- Original exception capture
- Creation of new error with cause
- Error description propagation
- Cause preservation
src/ScriptEngine/Machine/MachineInstance.cs (1)
1255-1259: LGTM! Proper implementation of nested exception support.The modification correctly passes the inner exception when creating a ParametrizedRuntimeException, enabling proper exception chaining.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
The changes focus on strengthening the error handling mechanism by allowing more detailed exception tracking and context preservation across the application's exception management system.